package hcom.model.main.dao;

import hcom.model.main.bean.MainBean;

import java.util.List;

import com.ibatis.dao.client.DaoManager;

import ecg.dao.DaoService;

public class MainDao {
	private static MainDao singleton;
	
	protected MainDao() {}
	
	public static MainDao getInstance() {
		if(singleton == null) {
			singleton = new MainDao();
		}
		
		return singleton;
	}
	
	private DaoManager	manager	= DaoService.getInstance();
	private IMain		main	= (IMain)manager.getDao(IMain.class, "hcom");
	
	/**
	 * 아이피 검사
	 * @param ipAddress
	 * @return
	 * @throws Exception
	 */
	public List<MainBean> checkIP(String ipAddress) throws Exception {
		MainBean mainBean = new MainBean();
		mainBean.setIp_address(ipAddress);
		
		return main.checkIP(mainBean);
	}
	
	/**
	 * 관리자 검사
	 * @param memNo
	 * @return
	 * @throws Exception
	 */
	public MainBean getAdminInfo(String memNo) throws Exception {
		MainBean mainBean = new MainBean();
		mainBean.setMem_no(memNo);
		
		return main.getAdminInfo(mainBean);
	}
	
	/**
	 * 팀장 검사
	 * @param memeNo
	 * @return
	 * @throws Exception
	 */
	public MainBean getLeaderInfo(String memeNo) throws Exception {
		MainBean mainBean  = new MainBean();
		mainBean.setMem_no(memeNo);
		
		return main.getLeaderInfo(mainBean);
	}
	
	/**
	 * 로그인 로그
	 * @param mainBean
	 * @throws Exception
	 */
	public void insertLoginLog(MainBean mainBean) throws Exception {
		System.out.println("다오 들어옴");
		main.insertLoginLog(mainBean);
	}
}
